 if (productCount >= MAX_PRODUCTS) {
        printf("商品数量已达上限！\n");
        pauseExecution();
        showProductManagement();
        return;
    }
    
    printf("请输入商品ID: ");
    int productId = getIntInput();
    
    // 检查商品ID是否已存在
    for (int i = 0; i < productCount; i++) {
        if (products[i].productId == productId) {
            printf("该商品ID已存在！\n");
            pauseExecution();
            showProductManagement();
            return;
        }
    }
    
    printf("请输入商品名称: ");
    getchar(); // 消耗换行符
    fgets(products[productCount].name, 50, stdin);
    products[productCount].name[strcspn(products[productCount].name, "\n")] = 0;
    
    printf("请输入商品类别: ");
    fgets(products[productCount].category, 50, stdin);
    products[productCount].category[strcspn(products[productCount].category, "\n")] = 0;
    
    printf("请输入商品价格: ");
    scanf("%f", &products[productCount].price);
    
    printf("请输入库存数量: ");
    scanf("%d", &products[productCount].stock);
    
    products[productCount].productId = productId;
    products[productCount].sales = 0;
    productCount++;
    
    printf("商品添加成功！\n");
    pauseExecution();
    showProductManagement();
}

// 显示订单管理
void showOrderManagement() {
    CLEAR_SCREEN;
    printf("==================== 电商平台订单处理与库存管理系统 - 订单管理 ====================\n\n");
    
    printf("订单列表:\n");
    printf("------------------------------------\n");
    printf("订单ID\t用户\t\t商品\t\t数量\t状态\t\t时间\n");
    printf("------------------------------------\n");
    
    for (int i = 0; i < orderCount; i++) {
        char timeStr[30];
        struct tm *timeInfo = localtime(&orders[i].orderTime);
        strftime(timeStr, sizeof(timeStr), "%H:%M:%S", timeInfo);
        
        printf("%d\t%-10s\t%-15s\t%d\t%-10s\t%s\n", 
               orders[i].orderId, 
               users[orders[i].userId - 1].name,
               products[orders[i].productId - 1].name,
               orders[i].quantity,
               getStatusName(orders[i].status),
               timeStr);
    }
    printf("------------------------------------\n\n");
    
    printf("1. 创建订单\n");
    printf("0. 返回上一级\n\n");
    printf("请选择: ");
    
    int choice = getIntInput();
    switch (choice) {
        case 1: createOrder(); break;
        case 0: showDashboard(); break;
        default: printf("无效选择！"); pauseExecution(); showOrderManagement();
    }
}

// 创建订单
void createOrder() {
    CLEAR_SCREEN;
    printf("==================== 电商平台订单处理与库存管理系统 - 创建订单 ====================\n\n");
    
    if (orderCount >= MAX_ORDERS) {
        printf("订单数量已达上限！\n");
        pauseExecution();
        showOrderManagement();
        return;
    }
    
    printf("用户列表:\n");
    for (int i = 0; i < userCount; i++) {
        printf("%d. %s\n", users[i].userId, users[i].name);
    }
    printf("请选择用户ID: ");
    int userId = getIntInput();
    
    // 检查用户是否存在
    int userExists = 0;
    for (int i = 0; i < userCount; i++) {
        if (users[i].userId == userId) {
            userExists = 1;
            break;
        }
    }
    if (!userExists) {
        printf("用户不存在！\n");
        pauseExecution();
        showOrderManagement();
        return;
    }
    
    printf("商品列表:\n");
    for (int i = 0; i < productCount; i++) {
        printf("%d. %s (?%.2f, 库存: %d)\n", 
               products[i].productId, 
               products[i].name,
               products[i].price,
               products[i].stock);
    }
    printf("请选择商品ID: ");
    int productId = getIntInput();
    
    // 检查商品是否存在
    int productExists = 0;
    for (int i = 0; i < productCount; i++) {
        if (products[i].productId == productId) {
            productExists = 1;
            break;
        }
    }
    if (!productExists) {
        printf("商品不存在！\n");
        pauseExecution();
        showOrderManagement();
        return;
    }
    
    printf("请输入购买数量: ");
    int quantity = getIntInput();
    
    // 检查库存
    for (int i = 0; i < productCount; i++) {
        if (products[i].productId == productId) {
            if (products[i].stock < quantity) {
                printf("库存不足！当前库存: %d\n", products[i].stock);
                pauseExecution();
                showOrderManagement();
                return;
            }
        }
    }
    
    // 创建订单
    orders[orderCount].orderId = orderCount + 1;
    orders[orderCount].userId = userId;
    orders[orderCount].productId = productId;
    orders[orderCount].quantity = quantity;
    orders[orderCount].orderTime = time(NULL);
    orders[orderCount].status = UNPAID;
    orderCount++;
    
    printf("订单创建成功！订单ID: %d\n", orders[orderCount-1].orderId);
    pauseExecution();
    showOrderManagement();
}

// 显示库存管理
void showInventoryManagement() {
    CLEAR_SCREEN;
    printf("==================== 电商平台订单处理与库存管理系统 - 库存管理 ====================\n\n");
    
    printf("库存概览:\n");
    printf("------------------------------------\n");
    printf("总库存价值: ?%.2f\n", 
           products[0].price * products[0].stock + 
           products[1].price * products[1].stock + 
           products[2].price * products[2].stock);
    printf("平均库存水平: 62%%\n");
    
    int lowStockCount = 0;
    for (int i = 0; i < productCount; i++) {
        if (products[i].stock < RESTOCK_THRESHOLD) {
            lowStockCount++;
        }
    }
    printf("低库存商品: %d\n", lowStockCount);
    printf("------------------------------------\n\n");
    
    printf("库存列表:\n");
    printf("------------------------------------\n");
    printf("商品ID\t名称\t\t类别\t\t价格\t库存\t预警值\n");
    printf("------------------------------------\n");
    
    for (int i = 0; i < productCount; i++) {
        printf("%d\t%-15s\t%-10s\t%.2f\t%d\t%d\n", 
               products[i].productId, 
               products[i].name,
               products[i].category,
               products[i].price,
               products[i].stock,
               RESTOCK_THRESHOLD);
    }
    printf("------------------------------------\n\n");
    
    printf("1. 处理补货任务\n");
    printf("0. 返回上一级\n\n");
    printf("请选择: ");
    
    int choice = getIntInput();
    switch (choice) {
        case 1: processRestock(); break;
        case 0: showDashboard(); break;
        default: printf("无效选择！"); pauseExecution(); showInventoryManagement();
    }
}
